#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
#include<vector>

using namespace std;


class Solution {
public:
    int sum(string s)
    {
        int sum = 0;
        
        for (int i = 0; i < s.size(); i++)
        {
            sum *= 10;
            sum += s[i] - '0';
        } 
        return sum;
    }
    string add(string num1, string num2)
    {
        int i1 = num1.size() - 1;
        int i2 = num2.size() - 1;
        int falg = 0;
        int sum = 1;
        while (i2 >= 0)
        {
            if (falg)
            {
                num1[i1] += falg;
                falg = 0;
            }
            num1[i1] += num2[i2] - '0';
            // cout << k << endl;
         
            if (num1[i1]>'9')
            {
                num1[i1] -= 10;
                falg = 1;
            }

           
            i1--;
            i2--;
        }
        while (falg && i1 >= 0)
        {
            num1[i1]++;
            falg = 0;
            if (num1[i1] > '9')
            {
                num1[i1] -= 10;
                falg = 1;
            }
            i1--;

        }
        if (falg)
        {
            string tmp = "1";
            tmp += num1;
            swap(num1, tmp);
        }
        return num1;
    }
    string multiply(string num1, string num2) {
        
        int i1 = num1.size() - 1;
        int i2 = num2.size() - 1;
        if (i2 > i1)
        {
            swap(num1, num2);
        }
        int size = sum(num2);
        string tmp = num1;
        for (int i = 0; i <size-1; i++)
        {
          num1 = add(num1,tmp);
        }
        return num1;
    }
};

class Solutionv {
public:
    vector<vector<int>> generate(int numRows) {
        vector<vector<int>> ret;
        for (int i = 0; i < numRows; i++) {
            if (i == 0) {
                vector<int> tmp;
                tmp.push_back(1);

                ret.push_back(tmp);
            }
            else if (i == 1) {
                vector<int> tmp;
                tmp.push_back(1);
                tmp.push_back(1);

                ret.push_back(tmp);

            }
            else {
                vector<int> tmp;
                for (int j = 0; j <= i; j++) {
                    if (j == 0 || j == i) {
                        tmp.push_back(1);
                    }
                    else {
                        tmp.push_back(ret[i - 1][j - 1] + ret[i - 1][j]);
                    }
                }
                ret.push_back(tmp);

               
            }

        }
        return ret;
    }
};
void test_vector()
{

    vector<vector<int>> ret;
   ret =  Solutionv().generate(2);
   
   
}

int main()
{

    test_vector();
    
    return 0;
}

//1 2 3
//4 5 6
//    18
//    1000
//    40000